


#ifndef PF_PEN_H
#define PF_PEN_H

#include "lx_define.h"
#include "pf_color.h"
#include "pf_flags.h"
#include "lx_Export.h"

/**
 * A pen stores attributes for painting such as line width,
 * linetype, color, ...
 *

 */
class LX_EXPORT PF_Pen : public PF_Flags {
public:
    /**
     * Creates a default pen (black, solid, width 0).
     */
    PF_Pen() : PF_Flags() {
        setColor(PF_Color(0,0,0));
        setWidth(LX_Define::Width00);
        setLineType(LX_Define::SolidLine);
		setScreenWidth(0);
    }
    /**
     * Creates a pen with the given attributes.
     */
    PF_Pen(const PF_Color& c,
           LX_Define::LineWidth w,
           LX_Define::LineType t) : PF_Flags() {
        setColor(c);
        setWidth(w);
        setLineType(t);
		setScreenWidth(0);
    }
    /**
     * Creates a default pen with the given flags. This is 
     * usually used to create invalid pens.
     *
     * e.g.:
     * <pre>
     *   PF_Pen p(LX_Define::FlagInvalid);
     * </pre>
     */
    PF_Pen(unsigned int f) : PF_Flags(f) {
        setColor(PF_Color(0,0,0));
        setWidth(LX_Define::Width00);
        setLineType(LX_Define::SolidLine);
		setScreenWidth(0);
    }
    //PF_Pen(const PF_Pen& pen) : PF_Flags(pen.getFlags()) {
    //    lineType = pen.lineType;
    //    width = pen.width;
    //    color = pen.color;
    //}
    virtual ~PF_Pen() {}

    LX_Define::LineType getLineType() const {
        return lineType;
    }
    void setLineType(LX_Define::LineType t) {
        lineType = t;
    }
    LX_Define::LineWidth getWidth() const {
        return width;
    }
    void setWidth(LX_Define::LineWidth w) {
        width = w;
    }
    double getScreenWidth() const {
        return screenWidth;
    }
    void setScreenWidth(double w) {
        screenWidth = w;
    }
    const PF_Color& getColor() const {
        return color;
    }
    void setColor(const PF_Color& c) {
        color = c;
    }
    bool isValid() {
        return !getFlag(LX_Define::FlagInvalid);
    }

    //PF_Pen& operator = (const PF_Pen& p) {
    //    lineType = p.lineType;
    //    width = p.width;
    //    color = p.color;
    //    setFlags(p.getFlags());

    //    return *this;
    //}

    bool operator == (const PF_Pen& p) const {
        return (lineType==p.lineType && width==p.width && color==p.color);
    }

    bool operator != (const PF_Pen& p) const {
        return !(*this==p);
    }

    friend std::ostream& operator << (std::ostream& os, const PF_Pen& p) {
        //os << "style: " << p.style << std::endl;
        os << " pen color: " << p.getColor()
        << " pen width: " << p.getWidth()
        << " pen screen width: " << p.getScreenWidth()
        << " pen line type: " << p.getLineType()
        << " flags: " << (p.getFlag(LX_Define::FlagInvalid) ? "INVALID" : "")
        << std::endl;
        return os;
    }


protected:
    LX_Define::LineType lineType;
    LX_Define::LineWidth width;
	double screenWidth;
    PF_Color color;
};

#endif
